package com.github.cakin.shiro.chapter12.entity;

import java.io.Serializable;

/**
 * @className: Permission
 * @description: 权限实体类
 * @date: 2020/5/19
 * @author: cakin
 */
public class Permission implements Serializable {
    /**
     * 权限id
     */
    private Long id;
    /**
     * 权限标识 程序中判断使用,如"user:create"
     */
    private String permission;
    /**
     * 权限描述,UI界面显示使用
     */
    private String description;
    /**
     * 是否可用,如果不可用将不会添加给用户
     */
    private Boolean available = Boolean.FALSE;

    /**
     * 功能描述：空构造函数
     *
     * @author cakin
     * @date 2020/5/19
     */
    public Permission() {
    }

    /**
     * 功能描述：构造函数
     *
     * @param permission  权限
     * @param description 描述
     * @param available   是否可用
     * @author cakin
     * @date 2020/5/19
     */
    public Permission( String permission, String description, Boolean available ) {
        this.permission = permission;
        this.description = description;
        this.available = available;
    }

    public Long getId() {
        return id;
    }

    public void setId( Long id ) {
        this.id = id;
    }

    public String getPermission() {
        return permission;
    }

    public void setPermission( String permission ) {
        this.permission = permission;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription( String description ) {
        this.description = description;
    }

    public Boolean getAvailable() {
        return available;
    }

    public void setAvailable( Boolean available ) {
        this.available = available;
    }
    @Override
    public boolean equals( Object o ) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        Permission role = (Permission) o;

        if (id != null ? !id.equals(role.id) : role.id != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "Role{"
                + "id=" + id
                + ", permission='" + permission + '\''
                + ", description='" + description + '\''
                + ", available=" + available
                + '}';
    }
}
